{extend name="main/index" /}
{block name="main"}
<div class="main-content">
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="#">经营管理模块</a>
            </li>
            <li class="active">投标费用管理</li>
        </ul><!-- .breadcrumb -->
        <div class="nav-search" id="nav-search">
            <form class="form-search">
                <span class="input-icon">
                    <input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
                    <i class="icon-search nav-search-icon"></i>
                </span>
            </form>
        </div><!-- #nav-search -->
    </div>

    <div class="page-content">
        <h3 class="header smaller lighter blue">投标项目费用统计</h3>
        <h3 class="header smaller lighter blue"><a href="{:url('admin/bids/feeAdd')}" class="btn btn-xs btn-primary show-btn">添加</a><a href="{:url('admin/bids/outExcel')}" class="btn btn-xs btn-info show-btn" style="float:right;">导出表格</a></h3>
        <div class="row">
            <div class="col-xs-12">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="table-responsive">
                            <table id="sample-table-2" class="table table-striped table-bordered table-hover">
                                <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th>项目名称</th>
                                        <th class="hidd240">购买招标文件费用(元)</th>
                                        <th class="hidden-240">制作投标文件费用(元)</th>
                                        <th class="hidden-240">综合服务费(元)</th>
                                        <th class="hidden-240">保证金(元)</th>
                                        <th class="hidden-240">其他费用(元)</th>
                                        <th class="hidden-240">总计(元)</th>
                                        <th class="hidden-240">操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                {volist name="res" id="v"}
                                    <tr>
                                        <td>{$v['id']}</td>
                                        <td>{$v['project_name']}</td>
                                        <td>{$v['buy_file_cost']}</td>
                                        <td>{$v['make_file_cost']}</td>
                                        <td>{$v['service_cost']}</td>
                                        <td>{$v['bond']}</td>
                                        <td>{$v['else_cost']}</td>
                                        <td>{$v['total_cost']}</td>
                                        <td>
                                            <a href="{:url('admin/bids/feeEdit',['id'=>$v['id']])}"  class="btn btn-xs btn-default " >修改</a>
                                            <button data-id="{$v['id']}" class="btn btn-xs btn-danger del-btn" >删除</button>
                                         </td>
                                    </tr>
                                {/volist}
                                {php}  
                                    $buy_file_cost = 0; 
                                    $make_file_cost = 0; 
                                    $service_cost = 0; 
                                    $bond = 0; 
                                    $else_cost = 0; 
                                    $total_cost = 0; 
                                {/php}
                                {volist name="res" id="v"}

                                    {php}  
                                        $buy_file_cost += $v['buy_file_cost']; 
                                        $make_file_cost += $v['make_file_cost']; 
                                        $service_cost += $v['service_cost']; 
                                        $bond += $v['bond']; 
                                        $else_cost += $v['else_cost']; 
                                        $total_cost += $v['total_cost']; 
                                    {/php}

                                {/volist}
                                        
                                    <!-- <tr> 
                                        <td>合计(元)</td>
                                        <td></td>
                                        <td id="fee1"></td>
                                        <td id="fee2"></td>
                                        <td id="fee3"></td>
                                        <td id="fee4"></td>
                                        <td id="fee5"></td>
                                        <td id="fee6"></td>
                                        <td></td>
                                    </tr> -->
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<input type="hidden" value="{$buy_file_cost}" id="cost1">
<input type="hidden" value="{$make_file_cost}" id="cost2">
<input type="hidden" value="{$service_cost}" id="cost3">
<input type="hidden" value="{$bond}" id="cost4">
<input type="hidden" value="{$else_cost}" id="cost5">
<input type="hidden" value="{$total_cost}" id="cost6">

{/block}

{block name="myjs"}
{js href="/static/admin/assets/js/toastr.min.js"}
<script>
    $(function(){
        $('.del-btn').click(function () {
            var ac_id = $(this).attr('data-id');
            if (confirm('你确定要 [ 删 除 ] 吗?')) {
                var obj = $(this).parents('tr');
                delAjax(ac_id, obj);
            }
        });
        var cost1 = document.getElementById('cost1').value;
        var cost2 = document.getElementById('cost2').value;
        var cost3 = document.getElementById('cost3').value;
        var cost4 = document.getElementById('cost4').value;
        var cost5 = document.getElementById('cost5').value;
        var cost6 = document.getElementById('cost6').value;
        var fee1 = document.getElementById('fee1');
        var fee2 = document.getElementById('fee2');
        var fee3 = document.getElementById('fee3');
        var fee4 = document.getElementById('fee4');
        var fee5 = document.getElementById('fee5');
        var fee6 = document.getElementById('fee6');
        fee1.innerHTML = cost1;
        fee2.innerHTML = cost2;
        fee3.innerHTML = cost3;
        fee4.innerHTML = cost4;
        fee5.innerHTML = cost5;
        fee6.innerHTML = cost6;
    });
    // 执行ajax删除
    function delAjax(id, obj) {
        $.ajax({
            type: 'delete',
            url: '/admin/bids/delFee/id/' + id,
            dataType: 'json',
            success: function (data) {
                if (data.status) {
                    toastr.success(data.info);
                    obj.remove();
                } else {
                    toastr.error(data.info, 'FBI WARNING:');
                }
            },
            error: function () {
                alert('AJAX执行失败');
            }
        });
    }

</script>

{/block}